COMMAND_STRIP = strip

DIR_BUILD = bin
DIR_PACKAGE = package
DIR_SOURCE = src
DIR_INSTALL = /usr/bin

NIM_COMPILER = nim
NIM_OPTS = -d:ssl -d:release --opt:speed
NIM_DEBUGOPTS = -d:ssl -d:verbose

CMUSTAT_BINNAME = cmus-status
CMUSTAT_BIN = $(DIR_BUILD)/$(CMUSTAT_BINNAME)
CMUSTAT_ENTRYFILE = $(DIR_SOURCE)/cmusStatus

all: clean makebindir cmustat_debug
release: clean makebindir cmustat stripbin
test: clean makebindir cmustat_debug run

install:
	mv $(DIR_BUILD)/$(CMUSTAT_BINNAME) $(DIR_INSTALL)/

clean:
	rm -rf $(DIR_BUILD)

makebindir:
	mkdir $(DIR_BUILD)

cmustat:
	$(NIM_COMPILER) c $(CMUSTAT_OPTS) -o:$(CMUSTAT_BIN) $(CMUSTAT_ENTRYFILE)

cmustat_debug:
	$(NIM_COMPILER) c $(CMUSTAT_DEBUGOPTS) -o:$(CMUSTAT_BIN) $(CMUSTAT_ENTRYFILE) 

stripbin:
	$(COMMAND_STRIP) $(DIR_BUILD)/*

run:
	cd $(DIR_BUILD); ./$(CMUSTAT_BINNAME)

